{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'echarts-gl':'https://assets.pyecharts.org/assets/echarts-gl.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"7b2ada191bea4ca09787bc914ea051b7\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'echarts-gl'], function(echarts) {\n",
       "                var chart_7b2ada191bea4ca09787bc914ea051b7 = echarts.init(\n",
       "                    document.getElementById('7b2ada191bea4ca09787bc914ea051b7'), 'white', {renderer: 'canvas'});\n",
       "                var option_7b2ada191bea4ca09787bc914ea051b7 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter3D\",\n",
       "            \"data\": [\n",
       "                [\n",
       "                    28,\n",
       "                    23,\n",
       "                    18\n",
       "                ],\n",
       "                [\n",
       "                    19,\n",
       "                    67,\n",
       "                    25\n",
       "                ],\n",
       "                [\n",
       "                    88,\n",
       "                    63,\n",
       "                    99\n",
       "                ],\n",
       "                [\n",
       "                    13,\n",
       "                    64,\n",
       "                    47\n",
       "                ],\n",
       "                [\n",
       "                    2,\n",
       "                    10,\n",
       "                    61\n",
       "                ],\n",
       "                [\n",
       "                    85,\n",
       "                    15,\n",
       "                    57\n",
       "                ],\n",
       "                [\n",
       "                    89,\n",
       "                    75,\n",
       "                    98\n",
       "                ],\n",
       "                [\n",
       "                    0,\n",
       "                    82,\n",
       "                    73\n",
       "                ],\n",
       "                [\n",
       "                    49,\n",
       "                    99,\n",
       "                    51\n",
       "                ],\n",
       "                [\n",
       "                    64,\n",
       "                    79,\n",
       "                    15\n",
       "                ],\n",
       "                [\n",
       "                    60,\n",
       "                    90,\n",
       "                    63\n",
       "                ],\n",
       "                [\n",
       "                    97,\n",
       "                    36,\n",
       "                    11\n",
       "                ],\n",
       "                [\n",
       "                    1,\n",
       "                    55,\n",
       "                    40\n",
       "                ],\n",
       "                [\n",
       "                    79,\n",
       "                    31,\n",
       "                    84\n",
       "                ],\n",
       "                [\n",
       "                    38,\n",
       "                    59,\n",
       "                    20\n",
       "                ],\n",
       "                [\n",
       "                    21,\n",
       "                    92,\n",
       "                    67\n",
       "                ],\n",
       "                [\n",
       "                    15,\n",
       "                    58,\n",
       "                    37\n",
       "                ],\n",
       "                [\n",
       "                    81,\n",
       "                    4,\n",
       "                    85\n",
       "                ],\n",
       "                [\n",
       "                    71,\n",
       "                    43,\n",
       "                    71\n",
       "                ],\n",
       "                [\n",
       "                    17,\n",
       "                    85,\n",
       "                    29\n",
       "                ],\n",
       "                [\n",
       "                    22,\n",
       "                    65,\n",
       "                    13\n",
       "                ],\n",
       "                [\n",
       "                    1,\n",
       "                    94,\n",
       "                    61\n",
       "                ],\n",
       "                [\n",
       "                    74,\n",
       "                    44,\n",
       "                    76\n",
       "                ],\n",
       "                [\n",
       "                    90,\n",
       "                    20,\n",
       "                    22\n",
       "                ],\n",
       "                [\n",
       "                    27,\n",
       "                    41,\n",
       "                    21\n",
       "                ],\n",
       "                [\n",
       "                    54,\n",
       "                    57,\n",
       "                    53\n",
       "                ],\n",
       "                [\n",
       "                    3,\n",
       "                    65,\n",
       "                    74\n",
       "                ],\n",
       "                [\n",
       "                    1,\n",
       "                    72,\n",
       "                    26\n",
       "                ],\n",
       "                [\n",
       "                    51,\n",
       "                    14,\n",
       "                    76\n",
       "                ],\n",
       "                [\n",
       "                    45,\n",
       "                    19,\n",
       "                    5\n",
       "                ],\n",
       "                [\n",
       "                    52,\n",
       "                    92,\n",
       "                    19\n",
       "                ],\n",
       "                [\n",
       "                    28,\n",
       "                    86,\n",
       "                    10\n",
       "                ],\n",
       "                [\n",
       "                    28,\n",
       "                    93,\n",
       "                    64\n",
       "                ],\n",
       "                [\n",
       "                    68,\n",
       "                    95,\n",
       "                    14\n",
       "                ],\n",
       "                [\n",
       "                    97,\n",
       "                    41,\n",
       "                    7\n",
       "                ],\n",
       "                [\n",
       "                    91,\n",
       "                    95,\n",
       "                    89\n",
       "                ],\n",
       "                [\n",
       "                    70,\n",
       "                    64,\n",
       "                    44\n",
       "                ],\n",
       "                [\n",
       "                    63,\n",
       "                    36,\n",
       "                    77\n",
       "                ],\n",
       "                [\n",
       "                    54,\n",
       "                    64,\n",
       "                    18\n",
       "                ],\n",
       "                [\n",
       "                    30,\n",
       "                    50,\n",
       "                    61\n",
       "                ],\n",
       "                [\n",
       "                    26,\n",
       "                    9,\n",
       "                    33\n",
       "                ],\n",
       "                [\n",
       "                    25,\n",
       "                    18,\n",
       "                    69\n",
       "                ],\n",
       "                [\n",
       "                    18,\n",
       "                    99,\n",
       "                    70\n",
       "                ],\n",
       "                [\n",
       "                    35,\n",
       "                    50,\n",
       "                    76\n",
       "                ],\n",
       "                [\n",
       "                    43,\n",
       "                    89,\n",
       "                    13\n",
       "                ],\n",
       "                [\n",
       "                    42,\n",
       "                    18,\n",
       "                    45\n",
       "                ],\n",
       "                [\n",
       "                    38,\n",
       "                    29,\n",
       "                    83\n",
       "                ],\n",
       "                [\n",
       "                    41,\n",
       "                    45,\n",
       "                    88\n",
       "                ],\n",
       "                [\n",
       "                    73,\n",
       "                    7,\n",
       "                    48\n",
       "                ],\n",
       "                [\n",
       "                    61,\n",
       "                    81,\n",
       "                    21\n",
       "                ],\n",
       "                [\n",
       "                    69,\n",
       "                    61,\n",
       "                    20\n",
       "                ],\n",
       "                [\n",
       "                    27,\n",
       "                    85,\n",
       "                    98\n",
       "                ],\n",
       "                [\n",
       "                    6,\n",
       "                    67,\n",
       "                    7\n",
       "                ],\n",
       "                [\n",
       "                    91,\n",
       "                    86,\n",
       "                    80\n",
       "                ],\n",
       "                [\n",
       "                    56,\n",
       "                    64,\n",
       "                    47\n",
       "                ],\n",
       "                [\n",
       "                    71,\n",
       "                    85,\n",
       "                    21\n",
       "                ],\n",
       "                [\n",
       "                    29,\n",
       "                    11,\n",
       "                    0\n",
       "                ],\n",
       "                [\n",
       "                    97,\n",
       "                    94,\n",
       "                    88\n",
       "                ],\n",
       "                [\n",
       "                    47,\n",
       "                    56,\n",
       "                    14\n",
       "                ],\n",
       "                [\n",
       "                    55,\n",
       "                    17,\n",
       "                    33\n",
       "                ],\n",
       "                [\n",
       "                    60,\n",
       "                    16,\n",
       "                    23\n",
       "                ],\n",
       "                [\n",
       "                    54,\n",
       "                    59,\n",
       "                    90\n",
       "                ],\n",
       "                [\n",
       "                    80,\n",
       "                    46,\n",
       "                    93\n",
       "                ],\n",
       "                [\n",
       "                    59,\n",
       "                    66,\n",
       "                    84\n",
       "                ],\n",
       "                [\n",
       "                    36,\n",
       "                    36,\n",
       "                    4\n",
       "                ],\n",
       "                [\n",
       "                    20,\n",
       "                    38,\n",
       "                    14\n",
       "                ],\n",
       "                [\n",
       "                    38,\n",
       "                    99,\n",
       "                    21\n",
       "                ],\n",
       "                [\n",
       "                    26,\n",
       "                    99,\n",
       "                    5\n",
       "                ],\n",
       "                [\n",
       "                    76,\n",
       "                    1,\n",
       "                    86\n",
       "                ],\n",
       "                [\n",
       "                    71,\n",
       "                    17,\n",
       "                    94\n",
       "                ],\n",
       "                [\n",
       "                    69,\n",
       "                    96,\n",
       "                    9\n",
       "                ],\n",
       "                [\n",
       "                    5,\n",
       "                    17,\n",
       "                    90\n",
       "                ],\n",
       "                [\n",
       "                    51,\n",
       "                    87,\n",
       "                    2\n",
       "                ],\n",
       "                [\n",
       "                    47,\n",
       "                    49,\n",
       "                    58\n",
       "                ],\n",
       "                [\n",
       "                    68,\n",
       "                    1,\n",
       "                    99\n",
       "                ],\n",
       "                [\n",
       "                    28,\n",
       "                    62,\n",
       "                    58\n",
       "                ],\n",
       "                [\n",
       "                    28,\n",
       "                    95,\n",
       "                    8\n",
       "                ],\n",
       "                [\n",
       "                    44,\n",
       "                    11,\n",
       "                    6\n",
       "                ],\n",
       "                [\n",
       "                    98,\n",
       "                    94,\n",
       "                    89\n",
       "                ],\n",
       "                [\n",
       "                    31,\n",
       "                    16,\n",
       "                    98\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 100,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#313695\",\n",
       "                \"#4575b4\",\n",
       "                \"#74add1\",\n",
       "                \"#abd9e9\",\n",
       "                \"#e0f3f8\",\n",
       "                \"#ffffbf\",\n",
       "                \"#fee090\",\n",
       "                \"#fdae61\",\n",
       "                \"#f46d43\",\n",
       "                \"#d73027\",\n",
       "                \"#a50026\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis3D\": {\n",
       "        \"nameGap\": 20,\n",
       "        \"type\": \"category\",\n",
       "        \"axisLabel\": {\n",
       "            \"margin\": 8\n",
       "        }\n",
       "    },\n",
       "    \"yAxis3D\": {\n",
       "        \"nameGap\": 20,\n",
       "        \"type\": \"category\",\n",
       "        \"axisLabel\": {\n",
       "            \"margin\": 8\n",
       "        }\n",
       "    },\n",
       "    \"zAxis3D\": {\n",
       "        \"nameGap\": 20,\n",
       "        \"type\": \"value\",\n",
       "        \"axisLabel\": {\n",
       "            \"margin\": 8\n",
       "        }\n",
       "    },\n",
       "    \"grid3D\": {\n",
       "        \"boxWidth\": 200,\n",
       "        \"boxHeight\": 100,\n",
       "        \"boxDepth\": 80,\n",
       "        \"viewControl\": {\n",
       "            \"autoRotate\": false,\n",
       "            \"autoRotateSpeed\": 10,\n",
       "            \"rotateSensitivity\": 1\n",
       "        }\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Scatter3D\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_7b2ada191bea4ca09787bc914ea051b7.setOption(option_7b2ada191bea4ca09787bc914ea051b7);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1d37af3e248>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 引入画图库\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Scatter3D\n",
    "from pyecharts.faker import Faker\n",
    "import random\n",
    "data = [(random.randint(0, 100), random.randint(0,\n",
    "                                                100), random.randint(0, 100))\n",
    "        for _ in range(80)]\n",
    "scatter3D = (Scatter3D().add(\"\", data).set_global_opts(\n",
    "    title_opts=opts.TitleOpts(\"Scatter3D\"),\n",
    "    visualmap_opts=opts.VisualMapOpts(range_color=Faker.visual_color)))\n",
    "\n",
    "scatter3D.render_notebook()\n",
    "# 下面的render方法是将图片保存在一个html页面到本地中\n",
    "# scatter3D.render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"8b7cecdc855340d9acb55ad0cd8299db\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_8b7cecdc855340d9acb55ad0cd8299db = echarts.init(\n",
       "                    document.getElementById('8b7cecdc855340d9acb55ad0cd8299db'), 'white', {renderer: 'canvas'});\n",
       "                var option_8b7cecdc855340d9acb55ad0cd8299db = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"name\": \"\\u9500\\u552e\\u989d\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\",\n",
       "                    \"value\": 124\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\",\n",
       "                    \"value\": 138\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\",\n",
       "                    \"value\": 120\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\",\n",
       "                    \"value\": 141\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\",\n",
       "                    \"value\": 116\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\",\n",
       "                    \"value\": 138\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\",\n",
       "                    \"value\": 78\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\",\n",
       "                    \"value\": 88\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\",\n",
       "                    \"value\": 86\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\",\n",
       "                    \"value\": 113\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\",\n",
       "                    \"value\": 107\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\",\n",
       "                    \"value\": 68\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u85cf\",\n",
       "                    \"value\": 51\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"zoom\": 1,\n",
       "            \"showLegendSymbol\": true,\n",
       "            \"emphasis\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u9500\\u552e\\u989d\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u9500\\u552e\\u989d\": true\n",
       "            },\n",
       "            \"show\": false,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Map\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"piecewise\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 200,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#50a3ba\",\n",
       "                \"#eac763\",\n",
       "                \"#d94e5d\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 14,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_8b7cecdc855340d9acb55ad0cd8299db.setOption(option_8b7cecdc855340d9acb55ad0cd8299db);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1d37af4a9c8>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 绘制地理图，画中国地图哈\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Map\n",
    "import random\n",
    "\n",
    "province = ['广东', '湖北', '湖南', '四川', '重庆', '黑龙江', '浙江', '山西', '河北', '安徽', '河南', '山东', '西藏']\n",
    "data = [(i, random.randint(50, 150)) for i in province]\n",
    "_map = (\n",
    "        Map()\n",
    "        .add(\"销售额\", data, \"china\")\n",
    "        .set_global_opts(\n",
    "            title_opts=opts.TitleOpts(title=\"Map\"),\n",
    "            legend_opts=opts.LegendOpts(is_show=False),\n",
    "            visualmap_opts=opts.VisualMapOpts(max_=200, is_piecewise=True),\n",
    "        )\n",
    "    )\n",
    "\n",
    "_map.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"62ec9f17f9ec4dccb31de7757e9d3ad9\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_62ec9f17f9ec4dccb31de7757e9d3ad9 = echarts.init(\n",
       "                    document.getElementById('62ec9f17f9ec4dccb31de7757e9d3ad9'), 'white', {renderer: 'canvas'});\n",
       "                var option_62ec9f17f9ec4dccb31de7757e9d3ad9 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{                                        offset: 0,                                        color: 'rgb(129, 227, 238)'                                    }, {                                        offset: 1,                                        color: 'rgb(25, 183, 207)'                                    }]),\n",
       "        new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{                                        offset: 0,                                        color: 'rgb(251, 118, 123)'                                    }, {                                        offset: 1,                                        color: 'rgb(204, 46, 72)'                                    }]),\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"name\": \"1990\\u5e74\",\n",
       "            \"symbolSize\": 10,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    28604,\n",
       "                    77,\n",
       "                    \"Australia\",\n",
       "                    17096869\n",
       "                ],\n",
       "                [\n",
       "                    31163,\n",
       "                    77.4,\n",
       "                    \"Canada\",\n",
       "                    27662440\n",
       "                ],\n",
       "                [\n",
       "                    1516,\n",
       "                    68,\n",
       "                    \"China\",\n",
       "                    1154605773\n",
       "                ],\n",
       "                [\n",
       "                    13670,\n",
       "                    74.7,\n",
       "                    \"Cuba\",\n",
       "                    10582082\n",
       "                ],\n",
       "                [\n",
       "                    28599,\n",
       "                    75,\n",
       "                    \"Finland\",\n",
       "                    4986705\n",
       "                ],\n",
       "                [\n",
       "                    29476,\n",
       "                    77.1,\n",
       "                    \"France\",\n",
       "                    56943299\n",
       "                ],\n",
       "                [\n",
       "                    31476,\n",
       "                    75.4,\n",
       "                    \"Germany\",\n",
       "                    78958237\n",
       "                ],\n",
       "                [\n",
       "                    28666,\n",
       "                    78.1,\n",
       "                    \"Iceland\",\n",
       "                    254830\n",
       "                ],\n",
       "                [\n",
       "                    1777,\n",
       "                    57.7,\n",
       "                    \"India\",\n",
       "                    870601776\n",
       "                ],\n",
       "                [\n",
       "                    29550,\n",
       "                    79.1,\n",
       "                    \"Japan\",\n",
       "                    122249285\n",
       "                ],\n",
       "                [\n",
       "                    2076,\n",
       "                    67.9,\n",
       "                    \"North Korea\",\n",
       "                    20194354\n",
       "                ],\n",
       "                [\n",
       "                    12087,\n",
       "                    72,\n",
       "                    \"South Korea\",\n",
       "                    42972254\n",
       "                ],\n",
       "                [\n",
       "                    24021,\n",
       "                    75.4,\n",
       "                    \"New Zealand\",\n",
       "                    3397534\n",
       "                ],\n",
       "                [\n",
       "                    43296,\n",
       "                    76.8,\n",
       "                    \"Norway\",\n",
       "                    4240375\n",
       "                ],\n",
       "                [\n",
       "                    10088,\n",
       "                    70.8,\n",
       "                    \"Poland\",\n",
       "                    38195258\n",
       "                ],\n",
       "                [\n",
       "                    19349,\n",
       "                    69.6,\n",
       "                    \"Russia\",\n",
       "                    147568552\n",
       "                ],\n",
       "                [\n",
       "                    10670,\n",
       "                    67.3,\n",
       "                    \"Turkey\",\n",
       "                    53994605\n",
       "                ],\n",
       "                [\n",
       "                    26424,\n",
       "                    75.7,\n",
       "                    \"United Kingdom\",\n",
       "                    57110117\n",
       "                ],\n",
       "                [\n",
       "                    37062,\n",
       "                    75.4,\n",
       "                    \"United States\",\n",
       "                    252847810\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"scatter\",\n",
       "            \"name\": \"2015\\u5e74\",\n",
       "            \"symbolSize\": 10,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    28604,\n",
       "                    81.8,\n",
       "                    \"Australia\",\n",
       "                    23968973\n",
       "                ],\n",
       "                [\n",
       "                    31163,\n",
       "                    81.7,\n",
       "                    \"Canada\",\n",
       "                    35939927\n",
       "                ],\n",
       "                [\n",
       "                    1516,\n",
       "                    76.9,\n",
       "                    \"China\",\n",
       "                    1376048943\n",
       "                ],\n",
       "                [\n",
       "                    13670,\n",
       "                    78.5,\n",
       "                    \"Cuba\",\n",
       "                    11389562\n",
       "                ],\n",
       "                [\n",
       "                    28599,\n",
       "                    80.8,\n",
       "                    \"Finland\",\n",
       "                    5503457\n",
       "                ],\n",
       "                [\n",
       "                    29476,\n",
       "                    81.9,\n",
       "                    \"France\",\n",
       "                    64395345\n",
       "                ],\n",
       "                [\n",
       "                    31476,\n",
       "                    81.1,\n",
       "                    \"Germany\",\n",
       "                    80688545\n",
       "                ],\n",
       "                [\n",
       "                    28666,\n",
       "                    82.8,\n",
       "                    \"Iceland\",\n",
       "                    329425\n",
       "                ],\n",
       "                [\n",
       "                    1777,\n",
       "                    66.8,\n",
       "                    \"India\",\n",
       "                    1311050527\n",
       "                ],\n",
       "                [\n",
       "                    29550,\n",
       "                    83.5,\n",
       "                    \"Japan\",\n",
       "                    126573481\n",
       "                ],\n",
       "                [\n",
       "                    2076,\n",
       "                    71.4,\n",
       "                    \"North Korea\",\n",
       "                    25155317\n",
       "                ],\n",
       "                [\n",
       "                    12087,\n",
       "                    80.7,\n",
       "                    \"South Korea\",\n",
       "                    50293439\n",
       "                ],\n",
       "                [\n",
       "                    24021,\n",
       "                    80.6,\n",
       "                    \"New Zealand\",\n",
       "                    4528526\n",
       "                ],\n",
       "                [\n",
       "                    43296,\n",
       "                    81.6,\n",
       "                    \"Norway\",\n",
       "                    5210967\n",
       "                ],\n",
       "                [\n",
       "                    10088,\n",
       "                    77.3,\n",
       "                    \"Poland\",\n",
       "                    38611794\n",
       "                ],\n",
       "                [\n",
       "                    19349,\n",
       "                    73.13,\n",
       "                    \"Russia\",\n",
       "                    143456918\n",
       "                ],\n",
       "                [\n",
       "                    10670,\n",
       "                    76.5,\n",
       "                    \"Turkey\",\n",
       "                    78665830\n",
       "                ],\n",
       "                [\n",
       "                    26424,\n",
       "                    81.4,\n",
       "                    \"United Kingdom\",\n",
       "                    64715810\n",
       "                ],\n",
       "                [\n",
       "                    37062,\n",
       "                    79.1,\n",
       "                    \"United States\",\n",
       "                    321773631\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"1990\\u5e74\",\n",
       "                \"2015\\u5e74\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"1990\\u5e74\": true,\n",
       "                \"2015\\u5e74\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"formatter\": function (param) {return param.data[2];},\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"type\": \"value\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                28604,\n",
       "                31163,\n",
       "                1516,\n",
       "                13670,\n",
       "                28599,\n",
       "                29476,\n",
       "                31476,\n",
       "                28666,\n",
       "                1777,\n",
       "                29550,\n",
       "                2076,\n",
       "                12087,\n",
       "                24021,\n",
       "                43296,\n",
       "                10088,\n",
       "                19349,\n",
       "                10670,\n",
       "                26424,\n",
       "                37062\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"type\": \"value\",\n",
       "            \"show\": true,\n",
       "            \"scale\": true,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"1990 \\u4e0e 2015 \\u5e74\\u5404\\u56fd\\u5bb6\\u4eba\\u5747\\u5bff\\u547d\\u4e0e GDP\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": false,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 20194354,\n",
       "        \"max\": 1154605773,\n",
       "        \"inRange\": {\n",
       "            \"symbolSize\": [\n",
       "                20,\n",
       "                50\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_62ec9f17f9ec4dccb31de7757e9d3ad9.setOption(option_62ec9f17f9ec4dccb31de7757e9d3ad9);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1d37d21c048>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Scatter\n",
    "from pyecharts.globals import ThemeType\n",
    "from pyecharts.commons.utils import JsCode\n",
    "\n",
    "# 人均寿命于GDP\n",
    "data = [[[28604,77,17096869,'Australia',1990],[31163,77.4,27662440,'Canada',1990],[1516,68,1154605773,'China',1990],[13670,74.7,10582082,'Cuba',1990],[28599,75,4986705,'Finland',1990],[29476,77.1,56943299,'France',1990],[31476,75.4,78958237,'Germany',1990],[28666,78.1,254830,'Iceland',1990],[1777,57.7,870601776,'India',1990],[29550,79.1,122249285,'Japan',1990],[2076,67.9,20194354,'North Korea',1990],[12087,72,42972254,'South Korea',1990],[24021,75.4,3397534,'New Zealand',1990],[43296,76.8,4240375,'Norway',1990],[10088,70.8,38195258,'Poland',1990],[19349,69.6,147568552,'Russia',1990],[10670,67.3,53994605,'Turkey',1990],[26424,75.7,57110117,'United Kingdom',1990],[37062,75.4,252847810,'United States',1990]],\n",
    "    [[44056,81.8,23968973,'Australia',2015],[43294,81.7,35939927,'Canada',2015],[13334,76.9,1376048943,'China',2015],[21291,78.5,11389562,'Cuba',2015],[38923,80.8,5503457,'Finland',2015],[37599,81.9,64395345,'France',2015],[44053,81.1,80688545,'Germany',2015],[42182,82.8,329425,'Iceland',2015],[5903,66.8,1311050527,'India',2015],[36162,83.5,126573481,'Japan',2015],[1390,71.4,25155317,'North Korea',2015],[34644,80.7,50293439,'South Korea',2015],[34186,80.6,4528526,'New Zealand',2015],[64304,81.6,5210967,'Norway',2015],[24787,77.3,38611794,'Poland',2015],[23038,73.13,143456918,'Russia',2015],[19360,76.5,78665830,'Turkey',2015],[38225,81.4,64715810,'United Kingdom',2015],[53354,79.1,321773631,'United States',2015]]]\n",
    "scatter = (Scatter()\n",
    "           .add_xaxis([i[0] for i in data[0]])\n",
    "           .add_yaxis(\"1990年\", [[i[1],i[3], i[2]] for i in data[0]],\n",
    "                      # 渐变效果实现部分\n",
    "                      color=JsCode(\"\"\"new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{\n",
    "                                        offset: 0,\n",
    "                                        color: 'rgb(251, 118, 123)'\n",
    "                                    }, {\n",
    "                                        offset: 1,\n",
    "                                        color: 'rgb(204, 46, 72)'\n",
    "                                    }])\"\"\"))\n",
    "           .add_yaxis(\"2015年\", [[i[1],i[3], i[2]]  for i in data[1]], \n",
    "                      # 渐变效果实现部分\n",
    "                      color=JsCode(\"\"\"new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{\n",
    "                                        offset: 0,\n",
    "                                        color: 'rgb(129, 227, 238)'\n",
    "                                    }, {\n",
    "                                        offset: 1,\n",
    "                                        color: 'rgb(25, 183, 207)'\n",
    "                                    }])\"\"\"))\n",
    "           .set_series_opts(label_opts=opts.LabelOpts(is_show=False))\n",
    "           .set_global_opts(\n",
    "               title_opts=opts.TitleOpts(title=\"1990 与 2015 年各国家人均寿命与 GDP\"),\n",
    "               tooltip_opts = opts.TooltipOpts(\n",
    "                   # 通过执行js代码实现提示显示为国家\n",
    "                   formatter=JsCode(\"function (param) {return param.data[2];}\")),\n",
    "               xaxis_opts=opts.AxisOpts(\n",
    "                   # 设置坐标轴为数值类型\n",
    "                   type_=\"value\", \n",
    "                   # 显示分割线\n",
    "                   splitline_opts=opts.SplitLineOpts(is_show=True)),\n",
    "               yaxis_opts=opts.AxisOpts(\n",
    "                   # 设置坐标轴为数值类型\n",
    "                   type_=\"value\",\n",
    "                   # 默认为False表示起始为0\n",
    "                   is_scale=True,\n",
    "                   splitline_opts=opts.SplitLineOpts(is_show=True),),\n",
    "               # 数据中第三个度量值通过图形的size来展示\n",
    "               visualmap_opts=opts.VisualMapOpts(is_show=False, type_='size', min_=20194354, max_=1154605773)\n",
    "    ))\n",
    "\n",
    "scatter.render_notebook() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
